package com.tencent.wxcloudrun.service.impl;

import java.time.LocalDateTime;
import java.util.List;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tencent.wxcloudrun.domain.TStoreProdType;
import com.tencent.wxcloudrun.mapper.TStoreProdTypeMapper;
import com.tencent.wxcloudrun.service.TStoreProdTypeService;

/**
 * @author ziyin.zhao
 * @description 针对表【t_store_prod_type(商品分类表)】的数据库操作Service实现
 * @createDate 2025-04-22 16:43:56
 */
@Service
public class TStoreProdTypeServiceImpl extends ServiceImpl<TStoreProdTypeMapper, TStoreProdType>
    implements TStoreProdTypeService {

    @Override
    public void deleteProdType(Long userId, Long prodTypeId) {
        LambdaUpdateWrapper<TStoreProdType> wrapper = new LambdaUpdateWrapper<>();
        wrapper.set(TStoreProdType::getDeleteFlag, 1);
        wrapper.set(TStoreProdType::getEnableFlag, 0);
        wrapper.set(TStoreProdType::getUpdatedTime, LocalDateTime.now());
        wrapper.set(TStoreProdType::getUpdatedBy, userId);
        wrapper.eq(TStoreProdType::getId, prodTypeId);
        this.update(wrapper);
    }

    @Override
    public List<TStoreProdType> listProdType() {
        LambdaQueryWrapper<TStoreProdType> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(TStoreProdType::getEnableFlag, 1);
        return this.list(queryWrapper);
    }
}
